import csv
from words import value

def triangleNrs():
    """Generates triangle nrs."""
    step = 1
    nr = 0
    while(True):
        nr += step
        step += 1
        yield nr
        
class TriangleNrChecker:
    def __init__(self):
        self.limit = 0
        self.generator = triangleNrs()
        self.numbers = set()
        
    def isTriangleNr(self, nr):
        while (self.limit < nr):
            self.limit = self.generator.next()
            self.numbers.add(self.limit)
            
        return nr in self.numbers
    
filename="words.txt"
    
file = open(filename, "r")
reader = csv.reader(file)    

words = reader.next()
checker = TriangleNrChecker()

print len([w for w in words if checker.isTriangleNr(value(w))])    
